package godraines.swing;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class aboutSwingProject extends JDialog {

	private final JPanel contentPanel = new JPanel();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public aboutSwingProject( JFrame parent ) {		// 12
		// 모달 대화상자를 만들기 위해 JDialog의 생성자 호출
		// JDK6에서 지원하는 모달대화상자 생성법 사용
		super( parent, ModalityType.APPLICATION_MODAL );			// 프로그램 전체에 모달창 적용										// 12
		
		setTitle("스윙 프로젝트에 관하여...");
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(new BorderLayout(0, 0));
		{
			JLabel lblNewLabel = new JLabel("");
			lblNewLabel.setIcon(new ImageIcon(aboutSwingProject.class.getResource("/images/about.png")));
			contentPanel.add(lblNewLabel, BorderLayout.WEST);
		}
		{
			JLabel lblNewLabel_1 = new JLabel("<html><pre>\r\n스윙 프로젝트 swing project v1::\r\n\r\n(c) Copyright 2014. godraines All rights Reserved.\r\nPowered by eclipse, windowbuilder.\r\n</pre>\r\n</html>");
			lblNewLabel_1.setToolTipText("");
			lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
			contentPanel.add(lblNewLabel_1, BorderLayout.CENTER);
		}
		{
			JSeparator separator = new JSeparator();
			contentPanel.add(separator, BorderLayout.SOUTH);
		}
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("   확인   ");
				okButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						//System.exit(0); 부모까지 종료 시켜버림. -> 몽땅 제거
						dispose();			// 현재 컴퍼넌트가 사용중인 리소스를 시스템에서 제거													// 13
					}
				});
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
		}
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);		// main에 있던 dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 를 dialog 지운채 사용
		setLocationRelativeTo(null);					// 2 화면 가운데 표시 시킴
	}

}
